﻿
Imports HotelLibrary

Public Class Registration
    Inherits System.Web.UI.Page
    Dim m_cust As New CustLib
    Dim loginCookie As New HttpCookie("Username")
    Dim custFunc As New CustomerFunction

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnRegister_Click(sender As Object, e As EventArgs) Handles btnRegister.Click
        m_cust.LoginID = txtLoginID.Text
        m_cust.Address = txtAddr.Text
        m_cust.City = txtCity.Text
        m_cust.Email = txtEmail.Text
        m_cust.FirstName = txtFName.Text
        m_cust.LastName = txtLName.Text
        m_cust.ZipCode = txtZip.Text
        m_cust.State = DropDownListState.SelectedItem.ToString
        Dim userHash As String = custFunc.hashFunction(txtLoginID.Text.ToLower)
        Dim passHash As String = custFunc.hashFunction(txtPassword.Text)
        Dim hash As String = custFunc.hashFunction(userHash & passHash)
        m_cust.Password = hash

        If (txtPassword.Text = txtCPassword.Text) Then
            If (custFunc.insertCustomer(m_cust)) Then
                lblFeedback.Text = "You are successfully Registered."
            Else
                lblFeedback.Text = "An error has occurred. Please contact admnistration staff. Thank you."
            End If
        Else
            lblFeedback.Text = "Password does not match"
        End If

        

    End Sub

    Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        Response.Redirect("Login.aspx")
    End Sub
End Class